"""
@name : 三乐购物系统
@author : maxueyan
@projectname: sanchuang
"""
import time
print("#################欢迎使用三乐购物系统################")
login = {"马雪燕":"123","施雅玲":"123","阿汤汤":"123"}
#定义用户字典
commodity = {'1':{'name':'荔枝','price':6.9,'time':0},'2':{'name':'苹果','price':4.5,'time':0},'3':{'name':'梨子','price':6.5,'time':0},'4':{'name':'芒果','price':12.6,'time':0}}
#定义商品字典

def login_system():
    while True:
        username = input("请输入你的账号：")
        userpasswd = input("请输入你的密码：")
        if username in login and userpasswd == login.get(username, 0):
            print("登陆成功！！！")
            break
        else:
            print("登陆失败！！")
#查看购物车
def shopping_info_02(shopping):
    if not shopping:
        print('你还没有添加任何商品到购物车！！')
    for i, j in shopping.items():
        print(f"该商品编号为{i},水果名为{j.get('name', 0)}，价格为{j.get('price', 0)}")

login_system()  # 登入
print(f"我们的商品如下，请查看：")
shopping_info_02(commodity)    # 商品展示

buy = []
choice = input("请输入你要购买商品的序号：")
while True:
    if choice == '1' :
        num = int(input("你好，荔枝6.9元一斤，请输入你要购买的斤数："))
        money = num*6.9
        print(f"一共是{money}块人民币")
        buy1 = ['荔枝', num * 6.9]
        buy.append(buy1)
    elif choice == '2' :
        num = int(input("你好，苹果4.5元一斤，请输入你要购买的斤数："))
        money = num*4.5
        print(f"一共是{money}块人民币")
        buy1 = ['荔枝', num * 4.5]
        buy.append(buy1)
    elif choice == '3' :
        num = int(input("你好，梨子6.5元一斤，请输入你要购买的斤数："))
        money = num*6.5
        print(f"一共是{money}块人民币")
        buy1 = ['荔枝', num * 6.5]
        buy.append(buy1)
    elif choice == '4' :
        num = int(input("你好，芒果12.6元一斤，请输入你要购买的斤数："))
        money = num*12.6
        print(f"一共是{money}块人民币")
        buy1 = ['荔枝', num * 12.6]
        buy.append(buy1)
    break

print("----------------购物车的清单-------------------")
for j in buy:
    print(buy)
    print("你购买了以上的商品")
    exit()
